﻿using Architecture.Api.Application.Command.MenuCommand;
using Architecture.Domain;
using Architecture.Domain.RBAC;
using Architecture.Service;
using MediatR;

namespace Architecture.Api.Application.CommandHandlers.MenuHandler
{
    public class MenuCreateCommandHandler : IRequestHandler<MenuCreateCommand, int>
    {
        protected readonly IMenuService menuService;

        public MenuCreateCommandHandler(IMenuService menuService)
        {
            this.menuService = menuService;
        }

        public async Task<int> Handle(MenuCreateCommand request, CancellationToken cancellationToken)
        {
            return await menuService.AddAsync(new Menu()
            {
                MenuName = request.MenuName,
                Url = request.Url,
                PId=request.PId
            });
        }
    }
}
